home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / FREAD.C < prev    next >
Text File  |  1986-05-18  |  1KB  |  35 lines

  1. /* 1.0  12-14-84                         (fread.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1984        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10. #include "stdio.h"
  11.  
  12. /************************************************************************/
  13.  
  14. fread(ptr, ptrsiz, nitems, fp)    /* Read nitems of data of type *ptr from
  15.                    FILE fp into block beginning at ptr.
  16.                    Return number of items read.        */
  17. /*----------------------------------------------------------------------*/
  18. FAST BUFFER ptr;
  19. FILE *fp;
  20. {
  21.     int items;
  22.     FAST int c, i;
  23.     METACHAR getc();
  24.  
  25.     for (items = 0; items < nitems; ++items)
  26.     {    for (i = ptrsiz; i; --i)
  27.         {    if ((c = getc(fp)) IS EOF)
  28.                 return items;
  29.  
  30.             *ptr++ = c;
  31.         }
  32.     }
  33.     return items;
  34. }
  35.